﻿<UserControl x:Class="TestCaseManagerApp.Views.TestCaseDetailedView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:local="clr-namespace:TestCaseManagerApp.Views"
             xmlns:convert="clr-namespace:TestCaseManagerCore.BusinessLogic.Converters;assembly=TestCaseManagerCore"
             mc:Ignorable="d" Loaded="UserControl_Loaded">
    <Grid>
        <Grid.Resources>
            <convert:TestStepPropertiesConverter x:Key="TestStepPropertiesConverter" />
        </Grid.Resources>
        <Grid.CommandBindings>
            <CommandBinding Command="{x:Static local:TestCasesInitialView.EditCommand}" Executed="EditButton_Click"/>
            <CommandBinding Command="{x:Static local:TestCasesInitialView.DuplicateCommand}" Executed="DuplicateButton_Click"/>
        </Grid.CommandBindings>
        <ProgressBar Name="progressBar" Minimum="0" Maximum="1" Height="16" IsIndeterminate="True" Margin="0,0,0,16" Visibility="Visible" />
        <Grid Name="mainGrid" Visibility="Hidden">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <StackPanel Orientation="Vertical">
                <TextBlock Text="Preview Test Case" Margin="10,0,10,30" Height="Auto" Width="Auto" FontSize="26" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0"/>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1.2*"/>
                        <ColumnDefinition Width="10*"/>
                        <ColumnDefinition Width="5*"/>
                        <ColumnDefinition Width="5*"/>
                        <ColumnDefinition Width="1.8*"/>
                        <ColumnDefinition Width="2.2*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="ID" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0"/>
                    <TextBox Text="{Binding TestCase.ITestCase.Id, Mode=OneWay}" Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="0" IsReadOnly="True"/>
                    <TextBlock Text="Title" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="1"/>
                    <TextBox Text="{Binding TestCase.Title, Mode=OneWay}" ToolTip="{Binding TestCase.Title, Mode=OneWay}" Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="1" IsReadOnly="True"/>
                    <TextBlock Text="Suite" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="2"/>
                    <TextBox Text="{Binding TestCase.ITestSuiteBase.Title, Mode=OneWay}" Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="2" IsReadOnly="True"/>
                    <TextBlock Text="Area" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="3"/>
                    <TextBox Text="{Binding TestCase.Area, Mode=OneWay}"  Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="3" IsReadOnly="True"/>
                    <TextBlock Text="Priority" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="4"/>
                    <TextBox Text="{Binding TestCase.Priority, Mode=OneWay}"  Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="4" IsReadOnly="True"/>
                    <TextBlock Text="Automated" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="5"/>
                    <TextBox Text="{Binding TestCase.ITestCase.IsAutomated, Mode=OneWay}" Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="5" IsReadOnly="True"/>
                </Grid>
                <Grid Name="gAssociatedAutomationInfo" Margin="0,30,0,30">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Automated Test Type" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="0"/>
                    <TextBlock Text="{Binding AssociatedAutomation.Type, Mode=OneWay}" Margin="10,0,10,0" Height="25" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="0"/>
                    <TextBlock Text="Automated test storage" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="1"/>
                    <TextBox Text="{Binding AssociatedAutomation.Assembly, Mode=OneWay}" Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="1" IsReadOnly="True"/>
                    <TextBlock Text="Automated test name" Margin="10,0,10,0" Height="25" FontWeight="Bold" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="2"/>
                    <TextBox Text="{Binding AssociatedAutomation.TestName, Mode=OneWay}" Margin="10,0,10,0" Height="25" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="2" IsReadOnly="True"/>
                </Grid>
            </StackPanel>

            <DataGrid ItemsSource="{Binding Path=ObservableTestSteps}" AutoGenerateColumns="False" Name="dgTestSteps" Height="Auto" Grid.Row="1" Margin="0,0,0,30" 
                      LoadingRow="dgTestSteps_LoadingRow" VirtualizingPanel.ScrollUnit="Pixel">
                <DataGrid.Columns>
                    <DataGridTemplateColumn   Header="Shared Step Name"  Width="150" MaxWidth="200" >
                        <DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTemplateColumn.HeaderStyle>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Title}" TextWrapping="Wrap"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn   Header="Steps"  Width="5*" >
                        <DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTemplateColumn.HeaderStyle>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ActionTitle}" TextWrapping="Wrap" />
                                <!--<TextBlock Text="{Binding ITestStep.Title, Converter={StaticResource TestStepPropertiesConverter}}" TextWrapping="Wrap" />-->
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn  Header="Expected Results" Width="5*">
                        <DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            </Style>
                        </DataGridTemplateColumn.HeaderStyle>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ActionExpectedResult}" TextWrapping="Wrap" />
                                <!--<TextBlock Text="{Binding ITestStep.ExpectedResult, Converter={StaticResource TestStepPropertiesConverter}}" TextWrapping="Wrap" />-->
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="2">
                <Button Name="btnEdit" Margin="0,0,0,30" Height="30" Width="90" Content="_Edit" VerticalAlignment="Center" Click="EditButton_Click"/>
                <Button Name="btnDuplicate" Margin="40,0,10,30" Height="30" Width="90" Content="_Duplicate" VerticalAlignment="Center" Click="DuplicateButton_Click"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2">
                <Button Name="btnPass" Margin="40,0,10,30" Height="30" Width="90" Content="Pass test" VerticalAlignment="Center" Click="btnPass_Click"/>
                <Button Name="btnFail" Margin="40,0,10,30" Height="30" Width="90" Content="Fail test" VerticalAlignment="Center" Click="btnFail_Click"/>
                <Button Name="btnBlock" Margin="40,0,10,30" Height="30" Width="90" Content="Block test" VerticalAlignment="Center" Click="btnBlock_Click"/>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
